You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > clVector Structure > clVector Methods > DotProd Method > clVector.DotProd Method (int, [In] TOpenCLMtxVec, [In] TOpenCLMtxVec, [In] TOpenCLMtxVec)
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
clVector.DotProd Method (int, [In] TOpenCLMtxVec, [In] TOpenCLMtxVec, [In] TOpenCLMtxVec)

Scalar product of two real arrays.

Syntax
C#
Visual Basic
public void DotProd(int DstIndex, [In] TOpenCLMtxVec Vec1, [In] TOpenCLMtxVec Vec2, [In] TOpenCLMtxVec Buffer);

Calculates the dot product (scalar value) of the calling object and Vec object and returns a real scalar value. The result is stored at specified index in the calling vector in the GPU memory. This variant of the function is non-blocking (faster), because the result does not have to be copied to the CPU memory to be used. 

The dot product is defined by the equation: 

 

Both objects must be of equal size. If they are not, the method will return the dot product of the largest sub-array.

using Dew.Math; using Dew.Math.Units; namespace Dew.Examples() { void Example() { TOpenCLVector a,b,c; double[] ac; clMtxVec.CreateIt(out a, out b, out c); try { a.SetIt(false, new double[] {1,2,3,4}); b.SetIt(false, new double[] {5,6,7,8}); c.DotProd(0, a, b); // c[0] = 1*5 + 2*6 + * 3*7 + 4*8 c.DotProd(1, a, b); // c[0] = 1*5 + 2*6 + * 3*7 + 4*8 c.DotProd(2, a, b); // c[0] = 1*5 + 2*6 + * 3*7 + 4*8 c.CopyToArray(ac); //ac = [70, 70, 70] } finally { clMtxVec.FreeIt(ref a,ref b, ref c); } } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!